﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.Services;
using IntelligentAgriculture.WebAPI.Application.Command.SheepCommand;
using IntelligentAgriculture.WebAPI.Application.Command.UserCommand;
using IntelligentAgriculture.WebAPI.Application.CommandHandler.UserCommandHandler;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepCommandHandler
{
    public class SheepQueryCommandHandler: IRequestHandler<SheepQueryCommand, Results<PageOutput<SheepOutPut>>>
    {
        private readonly ISheepService sheepService;
        private readonly ILogger<SheepQueryCommandHandler> logger;
        public SheepQueryCommandHandler(ISheepService sheepService, ILogger<SheepQueryCommandHandler> logger)
        {
           this.sheepService = sheepService;
           this.logger = logger;
        }

        /// <summary>
        /// 羊场查询列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<PageOutput<SheepOutPut>>> Handle(SheepQueryCommand request, CancellationToken cancellationToken)
        {
            var list = await sheepService.SheepFactoryList(request.Sheep);
            var results = Results<PageOutput<SheepOutPut>>.DataResult(list);
            return results;

        }


    }
      

  }




